﻿using System;
using System.Collections.Generic;
using System.Text;

namespace System.Linq
{
    public static class IEnumerableExecutionExtension
    {
        public static IEnumerable<TSource> ForEach<TSource> (this IEnumerable<TSource> source, Action<TSource> action)
        {
            foreach (var item in source)
            {
                action (item);
            }
            return source;
        }

        public static IEnumerable<TSource> ForEach<TSource> (this IEnumerable<TSource> source, Action<TSource, int> action)
        {
            int index = 0;
            foreach (var item in source)
            {
                action (item, index++);
            }
            return source;
        }
    }
}
